//
//  XYHeadLineView.m
//  新项目
//
//  Created by xmy on 2017/2/27.
//  Copyright © 2017年 xmy. All rights reserved.
//

#import "XYHeadLineView.h"
#import "SDCycleScrollView.h"

@interface XYHeadLineView () <SDCycleScrollViewDelegate>

@end

@implementation XYHeadLineView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    self.backgroundColor = [UIColor whiteColor];
    //大麦头条
    UIImageView *notificationView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"index_damaiheadlines"]];
    [self addSubview:notificationView];
    
    [notificationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(5);
        make.bottom.equalTo(self).offset(-7);
        make.left.equalTo(self.mas_left).offset(15);
        make.width.equalTo(@75);
    }];
    NSArray *titles = @[@"三生三世十里桃花",
                        @"感谢您的支持",
                        @"想要瘦的妹纸,往这里看哦",
                        @"大家都在围观!"
                        ];

    
    SDCycleScrollView *cycleScrollView4 = [[SDCycleScrollView alloc]init];
    cycleScrollView4.scrollDirection = UICollectionViewScrollDirectionVertical;
    cycleScrollView4.onlyDisplayText = YES;
    cycleScrollView4.titleLabelBackgroundColor = [UIColor whiteColor];
    cycleScrollView4.titleLabelTextColor = [UIColor blackColor];
    cycleScrollView4.delegate = self;
    NSMutableArray *titlesArray = [NSMutableArray new];
    [titlesArray addObjectsFromArray:titles];
    cycleScrollView4.titlesGroup = [titlesArray copy];

    [self addSubview:cycleScrollView4];
    
    [cycleScrollView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self);
        make.left.equalTo(notificationView.mas_right).offset(10);
    }];
    
}

- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", (long)index);
    
//    [self.navigationController pushViewController:[NSClassFromString(@"DemoVCWithXib") new] animated:YES];
    
    
}
@end
